package org.joyflow.core.instance;

import org.joyflow.core.common.R;
import org.joyflow.core.meta.Database;
import org.joyflow.core.meta.DbMeta;

public class DbFactory {
    private static DbFactory instance = new DbFactory();
    private DbFactory() {

    }

    public static DbFactory instance() {
        return instance;
    }

    public Object test(DbMeta dbMeta) {

        Database db = new Database(dbMeta);
        try {
            db.connect();
            return R.success();
        } catch (Exception e) {
            // ignore
        } finally {
            db.disconnect();
        }
        return R.error("Connection failed");
    }
}
